package com.lpl.mapper;
import com.lpl.polo.*;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface getIssues {
//    查询科目
    @Select("SELECT * " +
            "FROM bigt " +
            "WHERE title = IFNULL(#{name}, title)")
    List<Question> seckemi(String name);
    // 根据问题ID查询问题及t,
    @Select("select o.text,o.value,o.id FROM question q JOIN toption o ON q.id = o.question_id WHERE q.id =#{id}")
    List<Option> getQuestion(int id);

    @Select("select * from question where bigt_id=#{id}")
    List<Question> shitiiId(int id);

    @Select("select * from question where id=#{id}")
    Question seckemiId(int id);
//    插入科目
    @Insert("INSERT INTO bigt (title, subject,introduce) " +
            "VALUES ( #{title}, #{subject}, #{introduce})")
    void insetimu(kemu question);
@Delete("DELETE FROM bigt WHERE id = #{id};")
    void shanchu(String id);

    @Update("UPDATE bigt SET title = #{title}, subject = #{subject}, introduce = #{introduce} WHERE id = #{id}")
    void bianji(kemu data);

    @Select("SELECT * FROM question " +
            "WHERE (#{ipunt} IS NULL OR title LIKE CONCAT('%', #{ipunt}, '%')) " +
            "AND (#{status} IS NULL OR bigt_id = #{status})")
    List<Question> getTimu(tishai data);
    //    插入科目
    @Insert("INSERT INTO question (title,correct,subject,introduce,bigt_id) " +
            "VALUES ( #{title},#{correct}, #{subject}, #{introduce},#{bigt_id})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void IseTimu(newq data);
    @Insert("INSERT INTO toption (text,value,question_id) " +
            "VALUES ( #{text},#{value},#{bigt_id})")
    void Isexuan(Option data);
    @Delete("DELETE FROM question WHERE id = #{id}")
    void shanget(Integer id);
    @Delete("DELETE FROM toption WHERE question_id = #{id}")
    int shangets(Integer id);
    @Update("UPDATE question SET bigt_id=#{bigt_id}, title = #{title}, correct = #{correct}, subject = #{subject}, introduce = #{introduce} WHERE id = #{id}")
    int xiuti(newq data);
    @Update("UPDATE toption SET text = #{text}, value = #{value} WHERE id = #{id}")
    void xiutixuan(Option item);
    @Insert("INSERT INTO swiper (src,ref) " +
            "VALUES ( #{src},#{ref})")
    void tianjiatu(img data);
    @Select("Select * FROM swiper")
    List<img> getjiatu();
    @Delete("DELETE FROM swiper WHERE id = #{id}")
    void shanjiatu(int id);
}



